<?php
/**
 * 产品接口
 * @author czb
 *
 */
require(dirname(dirname(__FILE__))."/includes/initInterface.php");
require(dirname(dirname(__FILE__))."/includes/cls_goodsModel.php");
$action  = isset($_REQUEST['act']) ? trim($_REQUEST['act']) : '';
$goods  = new Goods();
$goods->$action();
Class Goods{
	private $m;//自己的model
	private $jsonp;
	public function __construct(){
		$this->jsonp = new JSONP();
		//基础信息构建
		$this->m = new goodsModel();
		//微信分享参数构建
	}
	
	public function getGoodsListByCatId(){
		global $_CODE;
		if(isset($_GET['cat_id'])){
			$info['cat_id'] = $_GET['cat_id'];
			$info['page'] = isset($_GET['page'])?intval($_GET['page']):1;
			$info['key'] = isset($_GET['key'])?$_GET['key']:"";
			$info['order'] = isset($_GET['order'])?$_GET['order']:"is_new";
			$res = $this->m->get_goods_list($info);
			die($this->jsonp->JSONP($_CODE['GOODS_GETGOODSLISTBYCATID_SUCCESS'],$res));
		}else{
			die($this->jsonp->JSONP($_CODE['GOODS_GETGOODSLISTBYCATID_ERROR']));
		}
	}
	
	public function getGoodsInfo(){
		global $_CODE;
		$id= isset($_GET['id'])?$_GET['id']:0;
		$res = $this->m->get_goods_info($id);
		die($this->jsonp->JSONP($_CODE['GOODS_GETGOODSINFO_SUCCESS'],$res));
	}
	
}